#!/usr/bin/env newlisp

(exec (string "cc65 -Oirs " (main-args 2) ".c"))
(exec "ca65 crt0.s")
(exec (string "ca65 " (main-args 2) ".s -g"))
(exec (string "ld65 -C nrom_32k_vert.cfg -o " (main-args 2) ".nes crt0.o " (main-args 2) ".o nes.lib -Ln labels.txt"))

(exec "rm *.o")

(exec "mv ./labels.txt ./BUILD")
(exec (string "mv ./" (main-args 2) ".s BUILD"))
(exec (string "mv ./" (main-args 2) ".nes BUILD"))

(exit)
